package fr.insee.sicape.format;

import java.util.ResourceBundle;

public abstract class FormaterFactory {

	protected static final String COLUMN = "c", SEPARATOR = "s";
	
	private FormaterFactory(){}
	
	public static Formater getFormater(){
		
		ResourceBundle bundle = ResourceBundle.getBundle("sicape");
		String file = bundle.getString("sicape.file");
		String missing = bundle.getString("sicape.missing");
		
		if(file.substring(0, 1).equalsIgnoreCase(COLUMN)){
			System.out.println("Type de sortie : fichier en colonnes");
			String positions = bundle.getString("sicape.positions");
			ColumnFormater formater = new ColumnFormater();
			formater.setMissing(missing);
			formater.setPositions(positions.split(","));
			return formater;
		}
		else{
			System.out.println("Type de sortie : fichier a separateur");
			String separateur = bundle.getString("sicape.separator");
			SeparatorFormater formater = new SeparatorFormater();
			formater.setMissing(missing);
			formater.setSeparator(separateur);
			return formater;
		}	
	}
}
